//引入字体图标样式
require("../../assets/fonts/iconfont.css");
//引入axios
const axios = require("../../assets/js/axios.js");
//引入自定义js
let obj = require("../../assets/js/my.js");
let addTabs = obj.addTabs;
let tab = obj.tab;
let $ = obj.$;
let local = obj.local;
//引入自己的样式
require("./mine.less");
document.addEventListener("DOMContentLoaded", function () {
	addTabs("mine");
	tab("#tab a", "active");
	//退出登录
	$(".quit").addEventListener("click", function () {
		location.href = "./login.html";
		local.clear();
	});
	//数据跳转
	$(".sports").addEventListener("click", function () {
		location.href = "motion_data.html";
	});
	//获取用户数据
	axios.get("/api/user/info").then((res) => {
		let data = res.data.data;
		if (res.data.errno === 0) {
			$("#imgUrl").src = axios.defaults.baseURL + data.imgUrl;
			$("#username").textContent = data.nickName;
			$("#runtime").textContent = (data.duration / 60).toFixed(2);
			$("#calorie").textContent = data.calorie;
			$("#sign").textContent = data.sign;
			$("#circlesCount").textContent = data.circlesCount;
		}
	});
});
